<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>
  <div id="app">

    <template v-if="type==='a'">
      username: <input type="text" />
    </template>


    <template v-else>
      password: <input type="password" />
    </template>

    <button @click="toggle"> toggle </button>


  </div>

  <script>

    var vm = new Vue({
      el: "#app",
      data: {
        type: 'a'
      },
      methods: {
        toggle() {
          this.type = this.type === 'a' ? "b" : "a";
        }
      }
    })

  </script>

</body>

</html>